package com.example.springboottools.utils;

import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;

public class GetHostIp {
    public static void main(String[] args) {
                PrintWriter writer = null;
                try {
                    // 创建或打开一个文件用于写入异常信息
                    writer = new PrintWriter(new FileWriter("D:\\staples\\logs\\error_log.txt", true), true); // 第二个参数为true表示追加模式
                    while (true) {
                        try {
                            System.out.println(1 / 0); // 故意抛出异常
                        } catch (Exception e) {
                            // 将异常信息输出到控制台的同时，也写入到文件中
                            e.printStackTrace(writer);
                        }
                    }
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                } finally {
                    if (writer != null) {
                        // 确保流关闭
                        writer.close();
                    }
                }
            }






}
